package com.thinkfit.jy.presenter;

import com.common.lib.bean.ProceduralTrainBean;
import com.common.lib.bean.VideoInfoBean;
import com.common.lib.mvp.BasePresenter;
import com.common.lib.network.HttpListener;
import com.common.lib.network.HttpMethods;
import com.common.lib.network.HttpObserver;
import com.thinkfit.jy.contract.ProceduralTrainingListContract;
import com.thinkfit.jy.utils.DeviceTypeUtils;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ProceduralTrainingListPresenter extends BasePresenter<ProceduralTrainingListContract.View> implements ProceduralTrainingListContract.Presenter {

    public ProceduralTrainingListPresenter(@NotNull ProceduralTrainingListContract.View rootView) {
        super(rootView);
    }

    @Override
    public void getVideoList(int type, int minTime,int maxTime) {
        HttpMethods.Companion.getInstance().getVideoList(DeviceTypeUtils.getDeviceType(),type,minTime,maxTime,100
                ,new HttpObserver(true, getRootView(), new HttpListener<ProceduralTrainBean>() {
                    @Override
                    public void onSuccess(@Nullable ProceduralTrainBean bean) {
                        if (getRootView() == null) {
                            return;
                        }
                        getRootView().getVideoListSuccess(bean);
//                        DataManager.Companion.getInstance().saveBannerList(list);
                    }

                    @Override
                    public void dataError(@Nullable int code, @Nullable String msg) {
                    }

                    @Override
                    public void connectError(@Nullable Throwable e) {
                    }
                }, getCompositeDisposable()));
    }

    @Override
    public void getWattinfo(int vid) {
        HttpMethods.Companion.getInstance().getWattinfo(vid,new HttpObserver(true, getRootView(), new HttpListener<VideoInfoBean>() {
                    @Override
                    public void onSuccess(@Nullable VideoInfoBean bean) {
                        if (getRootView() == null) {
                            return;
                        }
                        getRootView().getWattinfoSuccess(bean.getVideo());
//                        DataManager.Companion.getInstance().saveBannerList(list);
                    }

                    @Override
                    public void dataError(@Nullable int code, @Nullable String msg) {
                    }

                    @Override
                    public void connectError(@Nullable Throwable e) {
                    }
                }, getCompositeDisposable()));
    }

}
